package com.googlecode.guicespring.support;

import java.io.IOException;
import java.util.Properties;

import com.google.inject.internal.Preconditions;

public abstract class PropertiesLoaders {

	public static Properties classpath(String... names) {
		Properties properties = new Properties();
		
		for (String name : names) {
			try {
				properties.load(Preconditions.checkNotNull(
						Thread.currentThread().getContextClassLoader().getResourceAsStream(name),
						"Resource [" + name + "] doesn't exist."
					)
				);
			} catch (IOException e) {
				throw new RuntimeException("Failed to load properties : " + e.getMessage(), e);
			}
		}
		
		return properties;
	}

}
